package service;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
//执行插入member_information的服务类
public class InformationService {
	public void insertIntoMemInfo(Statement stmt,String name,int memId,int cardId,int times,String cardType){
		ResultSet rs = null;
		try{
				
			//如果times为0，不需要插入剩余使用次数，否则需要插入剩余次数
			if(times == 0){
					
				stmt.execute("insert into member_information (cardId,memberId,cardType) values ("+ cardId + "," + memId +","+ "'" + cardType + "'" +");");
				System.out.println("OK. A new " + cardType + " add to " + name + "("+("00"+memId).substring(("00"+memId).length()-3)+").");
					
			} else {
					
				stmt.execute("insert into member_information (cardId,memberId,cardType,lastTimes) values (" + cardId + "," + memId + "," + '\'' + cardType + '\'' + "," + times + ");");
				System.out.println("OK. A new " + cardType + " with " + times + " added to "+name + ".");
				
			}
		} catch (SQLException e){
			e.printStackTrace();
		}

	}
}
